package com.sjh.lib_app.statusMananger.defWidget

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import com.sjh.lib_app.statusMananger.StatusManager
import com.sjh.lib_app.statusMananger.StatusView
import com.sjh.lib_app.R
import java.lang.ref.WeakReference

/**
 * 正在加载中的状态
 * @author Extends
 * @date 2020/3/10/010
 */
class LoadingStatusView : StatusView() {
    companion object {
        const val LOAD_STATUS_RELOAD = "LoadingStatusView"
    }

    override fun createView(context: Context, statusManager: StatusManager): View {
        val view =
            (context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as android.view.LayoutInflater).inflate(
                R.layout.app_layout_loading_stat_view,
                null
            )
        val imageView = view.findViewById<ImageView>(R.id.img_rotate)
        view.setOnClickListener { statusManager.setOnClickEvent(LOAD_STATUS_RELOAD) }
        LoadingAnimator.circleAnimation(100f, WeakReference(imageView))
        return view
    }
}
